package com.hkd.common.core.controller;

import com.github.pagehelper.PageInfo;
import com.hkd.common.core.domain.TableDataInfo;
import com.hkd.common.core.enums.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;

import java.util.List;
@Slf4j
public class BaseController {
    public static TableDataInfo getTableDataInfo(List<?> questionVOList) {
        //校验查询结果
        if(CollectionUtils.isEmpty(questionVOList)){
            log.error(ResultCode.FAILED_DATA_NOT_EXIST.getMessage());
            return TableDataInfo.empty();
        }
        //获取数据总条数
        long total = new PageInfo<>(questionVOList).getTotal();

        return TableDataInfo.success(questionVOList,total);
    }
}
